package net.uhuijia.goods.goodspu.controller;

import net.uhuijia.vo.ResultMapVo;
import net.uhuijia.vo.good.GoodDetailVo;
import net.uhuijia.vo.good.GoodSkuDetailVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import net.uhuijia.appbase.controller.BaseController;
import net.uhuijia.goods.goodspu.persistence.model.GoodSpu;
import net.uhuijia.goods.goodspu.persistence.model.GoodSpuExample;
import net.uhuijia.goods.goodspu.service.GoodSpuService;


@RestController
@RequestMapping(value="/goodspu")
public class GoodSpuController
     extends BaseController<GoodSpuService,GoodSpu,GoodSpuExample> {

    @Autowired
    private GoodSpuService goodSpuService;

    /**
     * 商品详情页接口
     * @param spuId
     * @return
     */
    @RequestMapping(value ="detail",method = RequestMethod.GET)
    @ResponseBody
    public ResultMapVo<GoodDetailVo>  detail(String spuId){
        if(StringUtils.isEmpty(spuId))
            throw new IllegalArgumentException();
        GoodDetailVo goodDetailVo = this.goodSpuService.getGoodDetail(spuId);
        return ResultMapVo.ok(goodDetailVo);

    }
    /**
     * @Author xzj
     * @Description //获取商品规格属性弹窗详情
     * @Date  2018/10/6
     * @Param
     * @return
     **/
    @RequestMapping(value ="skuDetail",method = RequestMethod.GET)
    @ResponseBody
    public ResultMapVo<GoodSkuDetailVo>  skuDetail(String spuId){
        if(StringUtils.isEmpty(spuId))
            throw new IllegalArgumentException();
        GoodSkuDetailVo goodSkuDetailVo = this.goodSpuService.getGoodSkuDetail(spuId);
        return ResultMapVo.ok(goodSkuDetailVo);
    }

 }